package hanjia;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/10-下午9:00
 * Since  :   1.0
 * Version:   1.0
 */
public class LeetCode151 {

    public static String reverseWords(String s) {
        String[] split = s.trim().split(" ");
        StringBuffer stringBuffer = new StringBuffer();
        for (int i=split.length-1;i>=0;i--){
            if (!"".equals(split[i])){
                stringBuffer.append(split[i].trim());
                stringBuffer.append(" ");
            }


        }
        return stringBuffer.toString().trim();


    }

    public static void main(String[] args) {
       String s = "a good   example";
        System.out.println(reverseWords(s));
    }
}
